package vn.edu.nuce.dao;

import java.util.List;

import org.hibernate.SessionFactory;

import vn.edu.nuce.model.PhongMay;

public class PhongMayDaoImpl implements PhongMayDao{
	private SessionFactory sessionFactory;

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public List<PhongMay> getPhongMayList() {
		return getSessionFactory().getCurrentSession().createQuery("from PhongMay").list();
	}
	
	public List<PhongMay> getPhongMayHoatDong(){
		return getSessionFactory().getCurrentSession().createQuery("from PhongMay where status=1").list();
	}

	public PhongMay getById(String id) {
		return (PhongMay) getSessionFactory().getCurrentSession().get(PhongMay.class, id);
	}

	public void update(PhongMay phongMay) {
		getSessionFactory().getCurrentSession().update(phongMay);
	}

}
